home *** CD-ROM | disk | FTP | other *** search
- Message-ID: <3124E619.DC3@peoplesoft.com>
- Date: Fri, 16 Feb 1996 12:16:25 -0800
- From: Randal Kuramoto <randal_kuramoto@peoplesoft.com>
- Organization: PeopleSoft
- X-Mailer: Mozilla 2.0b6a (WinNT; I)
- MIME-Version: 1.0
- Newsgroups: comp.lang.c++
- Subject: temporary is rvalue or lvalue?
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- NNTP-Posting-Host: rkuramo2
- Path: ple-news-01.peoplesoft.com!
-
- I thought a temporary was an l-value. In the code below,
- is the application of the increment operator to the return value
- of Foo() in main() a compiler error? I even tried to specify
- const on the return type of Foo().
-
- struct X
- {
- X() : m_i( 0 ) {};
- X& operator++() { ++m_i; return( *this ); };
- int m_i;
- };
-
- const X Foo() { return X(); }
-
- int main( int, char** )
- {
- X x = ++Foo(); // BC4.52 and VC4.0 say it's okay
- return( 0 );
- }
-